<template>
  <div ref="chart">
  </div>
</template>

<script>
import echarts from 'echarts';
export default {
  name: 'Device',
  data () {
    return {
      chart: '',
      option: {
        title: {
          text: '连接类型',
          x: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        series: [
          {
            name: '连接类型',
            type: 'pie',
            radius: '55%',
            center: ['50%', '55%'],
            data: [
              {value: 35, name: 'TCP'},
              {value: 15, name: 'UDP'},
              {value: 20, name: 'MQTT'},
              {value: 30, name: 'HTTP'}
            ],
            labelLine: {
              length: 10,
              length2: 10
            },
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
    };
  },
  mounted () {
    this.chart = echarts.init(this.$refs['chart']);
    this.chart.setOption(this.option, true);
  }
};
</script>

<style scoped>
  .m-map {
    width: 100%;
    height: 100%;
  }
</style>
